bits 64

;void my_longjmp(jmp_buf jb, int value);
my_longjmp:
	mov rax, rdx

	mov rbx, [rcx + 0x08]
	mov rsp, [rcx + 0x10]
	mov rbp, [rcx + 0x18]
	mov rsi, [rcx + 0x20]
	mov rdi, [rcx + 0x28]
	mov r12, [rcx + 0x30]
	mov r13, [rcx + 0x38]
	mov r14, [rcx + 0x40]
	mov r15, [rcx + 0x48]
	;rip = [rcx + 0x50]
	ldmxcsr [rcx + 0x58]
	fnclex
	fldcw [rcx + 0x5C]
	movdqa xmm6, [rcx + 0x60]
	movdqa xmm7, [rcx + 0x70]
	movdqa xmm8, [rcx + 0x80]
	movdqa xmm9, [rcx + 0x90]
	movdqa xmm10, [rcx + 0xA0]
	movdqa xmm11, [rcx + 0xB0]
	movdqa xmm12, [rcx + 0xC0]
	movdqa xmm13, [rcx + 0xD0]
	movdqa xmm14, [rcx + 0xE0]
	movdqa xmm15, [rcx + 0xF0]
	jmp [rcx + 0x50]
	times 8 - ($ - $$ & 7) nop
